# -*- coding:utf-8 -*-

from rest_framework import serializers
from product.models import Product, Chipset


class ProductSerializer(serializers.ModelSerializer):
    class Meta:
        model = Product
        fields = "__all__"
        
        
class ChipsetSerializer(serializers.ModelSerializer):
    class Meta:
        model = Chipset
        fields = "__all__"
        
    def to_representation(self, item):
        data = super().to_representation(item)
        data['value'] = str(data['name'])
        data['text'] = str(data['name'])
        date_copy = data.copy()
        for key,value in data.items():
            if not value:
                date_copy.pop(key)
        return date_copy

        
        
        

